package com.cskaoyan.controller.wx;


import com.cskaoyan.service.WxCouponService;

import com.cskaoyan.service.WxService;
import com.cskaoyan.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

import java.util.List;
import java.util.Map;

@RestController
public class CouponWxController {

    @Autowired
    WxCouponService wxCouponService;
    @Autowired
    WxService wxService;

    @RequestMapping("wx/coupon/list")
    public BaseRespVo queryList(Integer page,Integer size){

        WxVo wxVo = wxCouponService.queryList(page, size);

        return BaseRespVo.ok(wxVo);
    }

    @RequestMapping("wx/coupon/mylist")
    public BaseRespVo queryMyList( Integer page, Integer status, Integer size){

        CouponVo_wx couponVoWx= wxCouponService.queryMyList(page,status,size);
        return BaseRespVo.ok(couponVoWx);
    }
    @RequestMapping("wx/coupon/exchange")
    public  BaseRespVo exchangeCoupoon(@RequestBody Map<String,String> map) {

        String code = map.get("code");
        wxCouponService.exchangeCoupoon(code);
        return BaseRespVo.ok();
    }
    @RequestMapping("wx/coupon/receive")
    public BaseRespVo receiveCoupon(@RequestBody Map<String,Integer> map ){

        Integer couponId = map.get("couponId");
        wxCouponService.receiveCoupon(couponId);
        return BaseRespVo.ok();
    }
//    @RequestMapping("wx/coupon/selectlist")
//    public BaseRespVo selectList(Integer cartId,Integer grouponRulesId,Integer addressId,Integer couponId){
//
//        List<CouponListMsgVo> coupons = wxCouponService.selectList(cartId,grouponRulesId,grouponRulesId,addressId);
//        return BaseRespVo.ok();
//    }
@RequestMapping("wx/user/index")
public BaseRespVo queryUser(){
    ResVo resVo = wxService.queryUserDetails();
    return BaseRespVo.ok(resVo);
}


}
